#ifndef __HTTP_H__
#define __HTTP_H__
#include <time.h>

#define DEFAULT_BUFFER_SIZE_HALF 512
#define DEFAULT_BUFFER_SIZE_BIG  1024
#define SESSION_NAME_SIZE   50
#define SESSION_VALUE_SIZE  50

#define DATA_NAME_LEN  50
#define DATA_VALUE_LEN 50

#define MAX_SESSION_CHAIN   10
#define MAX_POSITION_CHAIN  50

#define HOST_LEN 30
#define URI_LEN  50

#define F_SIZE 50

#define SESSION_TOKEN "ISESSION_ID="

typedef enum{HTTP_GET=0,HTTP_POST, HTTP_OTHER}request_type;

typedef struct buffer_tag
{
	char * pbuff;
	int    buff_size;
	int    used_size;
}buffer;

typedef struct session_pair_tag
{
	buffer * session_name;
	buffer * session_value;
	int is_null ;
}session_pair;
typedef struct session_tag
{
	session_pair * pair;
	time_t update_time;
	long   remote_ip;
	int is_null;
}session;
typedef struct request_data_tag
{
	buffer * name;
	buffer * value;
	struct request_data_tag * next;
}request_data;

typedef struct http_request_tag
{
	request_type rq_type;
	buffer *uri;
	buffer *host;
	session *request_session;
	request_data * get_data;
	request_data * post_date;

}http_request;

typedef struct action_function_tag
{
	long pt;
	char fname[32];
}action_function;

extern int http_main(char * buff);
extern int init_http();
extern http_request * malloc_request();
extern int parse_request(char * bf, http_request * http_rqt);
#endif
